package Demo4;

public class Test {
    public static void main(String[] args) {
        char[] ch = {'a','b','c'};
        String s1 = new String(ch);
        String s2 = "abc";
        System.out.println(s2 == s1);
        s1.intern();//1、先检查s1所指向的对象是否在常量池2、有则不入池，没有则入池
        System.out.println(s2 == s1);
    }
    public static void main1(String[] args) {
        String s1 = "hello";
        String s2 = "hello";
        System.out.println(s1 == s2);
        String s3 = new String("hello");
        String s4 = new String("hello");
        System.out.println(s1 == s3);
        System.out.println(s3 == s4);
    }
}
